package javabase.schoolwork.day6_12;

import org.junit.Test;

import java.util.HashSet;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;

/**
 * @author fance
 * @date 18-6-11 下午3:30
 */
public class SetSum {

    public void fun1()  {
        Set<String> stringSet = new HashSet<>();
        stringSet.add("a");
        stringSet.add("a");
        stringSet.add("a");
        System.out.println(stringSet.toString());
    }
    public void fun2()  {
        Set<String> stringSet = new HashSet<>();
        stringSet.add("c");
        stringSet.add("b");
        stringSet.add("b");
        stringSet.add("c");
        stringSet.add("a");
        System.out.println(stringSet.toString());
    }
    public void fun3()  {
        SortedSet<String> treeSet = new TreeSet<>();
        treeSet.add("a");
        treeSet.add("b");
        treeSet.add("c");
        treeSet.add("c");
        treeSet.add("c");
        treeSet.add("d");
        treeSet.add("e");

        System.out.println(treeSet.first());
        System.out.println(treeSet.last());
        System.out.println(treeSet.headSet("c"));
        System.out.println(treeSet.tailSet("c"));
        System.out.println(treeSet.subSet("b","d"));
    }
    @Test
    public void test() {
//        fun1();
//        fun2();
        fun3();
//        fun4();
    }
}
